<?php require_once('../../core/import.php');?>
<?php User::Permission('NEWS_RECYCLE_LIST'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/checkbox/import.checkbox.js"></script>
    <script type="text/javascript" src="../../scripts/components/zebra_table/import.zebra_table.js"></script>
    <script type="text/javascript" src="scripts/recycle.js"></script>
<!--二级联动开始-->
    <script language="JavaScript"> 
<?php
	$Data=DB::GetRows('select Identifying,Name,Identifying_Parent from `news_class` where Identifying_Parent is not null');
	$Data_Len=count($Data);
	$j=0
?>

	var num;
	var calArray=new Array();
<?php
	 for($i=0;$i<$Data_Len;$i++){
		 $Row_Class=$Data[$i]
?>
	calArray[<?php echo $i;?>]=new Array("<?php echo $Row_Class["Identifying"];?>","<?php echo $Row_Class["Name"];?>","<?php echo $Row_Class["Identifying_Parent"];?>");
<?php
$j=$j+1;
	 }
?>
	num=<?php echo $j;?>;
	function givevalue(myvalue){
	document.Form_select.SecondClass.length = 0;
	    for (i=0;i < num; i++)
		  {
			if (calArray[i][2] == myvalue)
			{
			 document.Form_select.SecondClass.options[document.Form_select.SecondClass.length] = new Option(calArray[i][1], calArray[i][0],"","");
			     
			}       
		   }
	}
	</script>
<!--二级联动结束-->
</head>

<body>
<form id="Form_select" name="Form_select" method="post" action="recycle.php">
    <table width="98.5%" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
        <th width="8%" height="25" align="right" valign="middle">新闻标题：&nbsp; </th>
        <th width="20%" height="25" align="left" valign="middle"><input type="text" name="Keyword" /></th>
        <th width="20%" height="25" align="left" valign="middle">
        		<select name="FirstClass" size="1" id="FirstClass" onChange="givevalue(document.Form_select.FirstClass.options[document.Form_select.FirstClass.selectedIndex].value)">
	  		<option value="">--请选择一级类别--</option> 
			<?php	
			$data=DB::GetRows('select Identifying,Name from `news_class` where Identifying_Parent is null');
			$data_first=$data[0]['Identifying'];
			print_r($data_first);
				  foreach($data as $Row)
				  {
                  ?>
                  <option value="<?php echo $Row['Identifying'];?>"> <?php echo $Row['Name'];?></option>
                  <?php 
                   	  }
                  ?>
                  </select>
        </th>
        <th width="20%" height="25" align="left" valign="middle">
        		<select name="SecondClass" size="1" id="SecondClass">
                    	 <option value="">--请选择二级类别--</option>
                  <?php
                   	 foreach(DB::GetRows('select Name,Identifying,Identifying_Parent from `news_class` where Identifying_Parent='.$data_first.'') as $Row)
                 		 {
                  ?>
                          <option value="<?php echo $Row["Identifying"];?>"><?php echo $Row["Name"];?></option>
                  <?php
                		 }
                  ?>
                  </select>
        </th>
        <th width="32%" height="25" align="left" valign="middle"><input type="submit" value="搜 索" /></th>
    </tr>
    </thead>
    </table>
    </form>
    <table width="98.5%" id="List" border="0" cellpadding="0" cellspacing="0" class="List">
    <thead>
    <tr>
        <th width="5%" height="25" align="center" valign="middle">选取</th>
        <th width="40%" align="left" valign="middle">&nbsp;标题</th>
        <th width="20%" align="center" valign="middle">类别</th>
        <th width="20%" align="center" valign="middle">发布时间</th>
        <th width="19%" align="center" valign="middle">&nbsp;</th>
    </tr>
    </thead>    
    <tbody>
    <form id="Form1" name="Form1" method="post" action="recycle.action.batch_delete.php">
    <?php
        #获取数据
	  $Keyword=trim(Functions::HttpArgs('Keyword'));
	  $FirstClass=trim(Functions::HttpArgs('FirstClass'));
	  $SecondClass=trim(Functions::HttpArgs('SecondClass'));
	  $Wheres="where M_IsDelete=1 ";
	  
	  if($FirstClass)
	      {
		  $Wheres=$Wheres." and ClassID=$FirstClass ";
	 	}
	  if($SecondClass)
	      {
		  $Wheres=$Wheres." and SubclassID=$SecondClass ";
	 	}
	  if($Keyword)
	      {
		  $Wheres=$Wheres." and Title like '%$Keyword%' ";
	 	}
	  $Orders=$Wheres.' order by M_IsHeadline desc,M_IsHeadline_Datetime desc,M_IsRecommend desc,M_IsRecommend_Datetime desc,M_IsTop desc,M_IsTop_Datetime desc,DateTime desc';	  
        $Data=DB::GetData('select ID,ClassID,SubclassID,Title,DateTime,M_IsHeadline,M_IsRecommend,M_IsTop from news '.$Orders.' limit ?,15');
        foreach($Data['Record'] as $Row)
        {
    ?>
    <tr>
        <td height="25" align="center" valign="middle">
            <input id="ID" name="ID[]" type="checkbox" value="<?php echo $Row['ID']; ?>" class="Cursor_Pointer" />
        </td>
        <td height="25" valign="middle">
        <?php 
	  	$Title_Len=50;
	  	if($Row['M_IsHeadline'])
			{
				echo '<font color="red">【头条】</font>';
				$Title_Len=$Title_Len-4;
			}
		if($Row['M_IsTop'])
			{
				echo '<font color="green">【置顶】</font>';
				$Title_Len=$Title_Len-4;
			}
		if($Row['M_IsRecommend'])
			{
				echo '<font color="orange">【推荐】</font>';
				$Title_Len=$Title_Len-4;
			}
	   ?>
            &nbsp;<a href="select.php?id=<?php echo $Row['ID']; ?>"><?php echo Functions::SubStr($Row['Title'],$Title_Len); ?></a>
        </td>
        <td height="25" align="center" valign="middle">
            <?php 
		if($Row['ClassID'])
			{
				$Date_Class=DB::GetRowByID('news_class','Identifying:'.$Row['ClassID']);
				echo $Date_Class['Name'];	
			}
		if($Row['SubclassID']!=null)
			{
				$Date_SubClass=DB::GetRowByID('news_class','Identifying:'.$Row['SubclassID']);
				echo '-'.$Date_SubClass['Name'];	
			}
		 ?>
        </td>
        <td height="25" align="center" valign="middle">
            <?php echo $Row['DateTime'];?>
        </td>
        <td height="25" align="center" valign="middle">
            <a href="select.php?id=<?php echo $Row['ID']; ?>">查看</a>
            <a href="recycle.action.revert.php?id=<?php echo $Row['ID']; ?>">恢复</a>
            <a href="javascript:mconfirm_delete('recycle.action.delete.php?id=<?php echo $Row['ID']?>');">彻底删除</a>
        </td>
    </tr>
    <?php
        }
    ?>
    </form>
    </tbody>    
    <tfoot>
    <tr>
        <td height="25" colspan="5" align="center" valign="middle">
            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td width="55%" align="left">
                <?php
                    PagerFactory::Create('Simple')->Display($Data,array
			  (
			  	'Parameters'=>array(
					'Keyword'=>$Keyword,
					'FirstClass'=>$FirstClass,
					'SecondClass'=>$SecondClass
				)
				
			  ));
                ?>
                </td>
                <td width="45%" align="right">
                    <span id="SelectAll" class="Cursor_Pointer">全选</span>/<span id="UnSelectAll" class="Cursor_Pointer">全不选</span>
                    选中项：<span id="Delete" class="Cursor_Pointer">彻底删除</span>&nbsp;/&nbsp;<span id="revert" class="Cursor_Pointer">恢复</span>             
                </td>
            </tr>
            </table>    
         </td>
	</tr>
    </tfoot>    
    </table>
</body>
</html>